package com.xlisteven.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xlisteven.entity.Product;
import com.xlisteven.mapper.ProductMapper;
import com.xlisteven.service.IProductService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService {

    @Resource
    ProductMapper productMapper;

    @Override
    public List<Product> getProductList(Long userId) {
        LambdaQueryWrapper<Product> wrapper = new QueryWrapper<Product>().lambda();
        wrapper.eq(Product::getUserId, userId);
        return productMapper.selectList(wrapper);
    }

    @Override
    public void insert(List<Product> productList) {
        this.saveBatch(productList);
    }
}
